#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/wait.h>
#include<string.h>
void mysys(char *command)
{
	char buffer[100];
	char item[10][20];
	char *word;
	char *argv[5];
	strcpy(buffer,command);
	word=strtok(buffer," ");
	int i=0,j;
	while(word!=NULL){
		strcpy(item[i++],word);
		word=strtok(NULL," ");
	}
	for(j=0;j<i;++j){
		argv[j]=(char*)malloc(sizeof(char)*20);
		strcpy(argv[j],item[j]);
	}
	argv[j]=NULL;
	pid_t pid;
	pid=fork();
	if(pid==0){
		int error=execvp(argv[0],argv);
		if(error<0){
			perror("execvp");
		}
		exit(127);
	}
	for(j=0;j<=i;++j){
		free(argv[j]);
	}
	wait(NULL);
}
int main()
{
    printf("--------------------------------------------------\n");
    mysys("echo HELLO WORLD");
    printf("--------------------------------------------------\n");
    mysys("ls /");
    printf("--------------------------------------------------\n");
    return 0;
}
